<?php
$str = "ياخشىمۇسىز";
$par = [
	"from" => 'zh',
	"to" => 'uy',
	"apikey" => '1cfa151e3daf90dce598404dc9ef34e0',
	"src_text" => $str
];
if(preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)){
}else{
	$par['from'] = 'uy';
	$par['to'] = 'zh';
}

echo httpGet("https://free.niutrans.com/NiuTransServer/translation?".http_build_query($par));

/**
 * GET请求
 */
function httpGet($url)
{
	$ch = curl_init();
	$header = array(
		'Content-Type: application/json');
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$tmpInfo = curl_exec($ch);
	if (curl_errno($ch)) {
		return curl_error($ch);
	}
	curl_close($ch);
	return $tmpInfo;
}